<?php
namespace api\models;

class TTest extends \common\models\TTest{

    public static $FIELDS_KEY = '';

    public function scenarios()
    {
        $scenarios = parent::scenarios();
        /** 添加应用场景 接受参数 */
        $scenarios['add'] = [
            'name', 'sex'
        ];
        $scenarios['del'] = [
            'id'
        ];
        $scenarios['modify'] = [
            'id','remark'
        ];
        $scenarios['find'] = [
            'remark'
        ];
        return $scenarios;;
    }

    public function rules()
    {
        $rules = parent::rules();
        $rules[] =  [['name','sex','remark'], 'required','on'=>'add'];
        $rules[] =  [['id'], 'required','on'=>'del'];
        $rules[] = [['id','remark'],'required','on'=>'modify'];
        $rules[] = [['remark'],'required','on'=>'find'];
        return $rules;
    }

    public function fields()
    {
        $fields = parent::fields(); // TODO: Change the autogenerated stub
        $fields['default'] = [
            'id',
            'name',
            'sex',
            'remark'
        ];
        $fields['add'] = [
            'id',
          'name',
        ];
        $fields['del'] = [
            'id'
        ];
        $fields['modify'] = [
            'id',
            'remark'
        ];
        $fields['find'] = [
            'id',
            'name',
            'remark'

        ];
        return $fields[static::$FIELDS_KEY];;
    }
}